﻿using Microsoft.Phone.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace NapThe
{
    public partial class Khac : UserControl
    {
        
        Grid MainLayoutRoot;
        NapXu napxu;

        public Khac(Grid MainLayoutRoot,NapXu napxu)
        {
            InitializeComponent();
            this.MainLayoutRoot = MainLayoutRoot;
            this.MainLayoutRoot.Children.Add(this);
            this.napxu = napxu;
        }
       
        public void OnVisible()
        {
            this.Visibility = Visibility.Visible;
            
        }
        public void OnCollapsed()
        {
            this.Visibility = Visibility.Collapsed;
            listBox1.SelectedIndex = -1;
        }
        private void SelectionChanged_Item(object sender, SelectionChangedEventArgs e)
        {
            string t = this.listBox1.SelectedItem as string;
            int i = listBox1.SelectedIndex;
            if (i != -1)
            {
                if (i == 0)
                {
                    MessageBoxResult m =
                            MessageBox.Show("Bạn có muốn nạp thẻ với giá ưu đãi 15.000 đồng được 30.000 ngọc không ?", "Nạp tiền", MessageBoxButton.OKCancel);
                    if (m == MessageBoxResult.OK)
                    {
                        SmsComposeTask smsComposeTask = new SmsComposeTask();
                        smsComposeTask.To = SMSModel.address;
                        smsComposeTask.Body = SMSModel.content;
                        smsComposeTask.Show(); // this will invoke the native sms edtior
                        listBox1.SelectedIndex = -1;
                    }
                    if (m == MessageBoxResult.Cancel)
                    {
                        OnCollapsed();
                        napxu.naptheQplay.OnVisible();
                    }
                }
                if (i == 1)
                {
                    OnCollapsed();
                    napxu.naptheQplay.OnVisible();
                }
            }

        }
    }
}
